package com.foreknow.springboot.threaddemo;

/**
 * @author xiaoming
 * @version jdk1.8
 * @date 2022/8/11 14:46
 * @function:
 */
public class SleepDemo {
    public static void main(String[] args) {
        new Thread("线程1"){
            @Override
            public void run() {
                for (int i = 0; i < 10; i++) {
                    //线程休眠
                    try {
                        Thread.sleep(500);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.println(getName()+"执行了!!!!!!!!!");
                }
            }
        }.start();

        new Thread("线程2"){
            @Override
            public void run() {
                for (int i = 0; i < 10; i++) {
                    //线程休眠
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.println(getName()+"执行了!!!!!!!!!");
                }
            }
        }.start();
    }
}
